home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
ACORNUSERS
/
CBSA
/
COMPUTER
/
WIMP2
/
Readme
< prev
next >
Wrap
Text File
|
1999-05-19
|
14KB
|
253 lines
Readme for Wimp2 v0.36
-=-=-=-=-=-=-=-=-=-=-=
(C) 1994-1999 N. Douglas
*** This project is dedicated to the memory of my late mother who died ***
*** during its original development ***
Welcome to the Wimp enhancer module. Enclosed is a module, Wimp2, which
provides preemptive multitasking facilities for all versions of RISC-OS from
RO2 to RO4. Also enclosed is a Wimp2 task manager, !Wimp2Ctrl, which allows
monitoring and control of Wimp2 tasks (along with a natty CPU usage
indicator).
Also included is the application !Wimp2Demo which demonstrates Wimp2 in
action. Feel free to run as many copies as you like and watch how desktop
speed is unimpaired. BTW, make sure each is loaded in before you run another
- the Wimp_OpenTemplate bug (see below) shows up otherwise.
Also available is a patch (written by Andrew Teirney) which intercepts
normal wimp SWI's and patches them to call Wimp2. This patch application
allows lists of applications that can be patched and those which can't, see
the patch documentation for more details. A link to the patch's website is
available from the Wimp2 website (see below).
History:
-=-=-=-=
Many many years ago in 1994 there was born an idea for the regeneration
of RISC-OS called Tornado. This was born out of my discussions on fidonet
with other Acorn enthusiasts about how RO was stagnating and how something
needed to be done. This project generated a huge groundswell of thought and
it featured in Acorn User a number of times.
However, it became clear to me in 1996 that RISC-OS was beyond salvation,
and there were already far better development systems out there (WinNT).
Hence Tornado was ditched in favour of Tornado II, a portable version of
tornado encompassing the ideas within the original. Development continues on
Tornado II to this day (see http://www.nedprod.com/tornado).
However, in the christmas of 1996 when a RISC-OS port of Tornado II was
still feasible, I wrote the Tornado II support module (v0.12) and released
this to hensa. I continued its development, including a patch to force all
normal RO tasks to use the new preemptive multitasker, but this was curtailed
by the untimely and sudden death of my mother. Subsequently, the project was
ditched for the remainder of those christmas holidays, and the 1997 holidays
were marred by fiance troubles, and so coming towards the 1998 holidays I
resolved to finish what I had started - now not for Tornado II, but for its
own sake.
Hence, I would like to dedicate this project to the memory of my mother,
who died during its initial creation. May she rest in peace.
Introduction:
-=-=-=-=-=-=-
For as long as I can remember, many programmers in the Acorn scene
have said that bringing preemptive multitasking to RISC-OS would require a
complete restructuring of how applications are constructed and hence it was
too great a project for Acorn to consider, and hence they could be forgiven
for not implementing it in new versions of RO. As I said then, and prove now,
that is complete bunkum. The restructuring necessary is minimal, and
multithreading support isn't much harder. It was simply that Acorn management
were incompetent and they dropped the ball and prevented talented Acorn
programmers from keeping the operating system up to date.
Indeed, as shown by the patch by Andrew Teirney, it shouldn't be too hard
to make existing applications fully preempted too, although there are great
benefits to using Wimp2 natively (mainly speed and control and stability).
In addition, it would not require much work to implement memory
protection, ensuring that tasks do not and cannot cause operating system
instability. Why these things have not been implemented in at least RO3.5
never mind RO3.1 I cannot fathom, but it doesn't really matter anymore now
anyway. Acorn is going down the tubes through their own doing, and they have
destroyed a wonderful thing in doing so. The original Archimedes A400 series
running RISC-OS 2 was an incredible sight in its day, and it is a testament
to its programmers that it has lasted so long and far. It is just a shame
that the dream was so spoilt as it was.
However, I and many other Acorn programmers can now thank our Acorn
heritage as we write software for other platforms. I produce software many
other programmers envy, and I can only thank Acorn for this.
This is my belated contribution to the benefit of RISC-OS I promised way
back in 1994 when promising tornado, and it is far less spectacular than that
which I promised, but I hope it will do to some part. I also hope that the
many people who still spit on any mention of my name in the newsgroups will
forgive me for not delivering tornado, and I hope they understand at least
partly why. My apologies go to them and to all Acorn enthusiasts - I let you
down, and I apologise. Maybe if I had come through Phoebe would be selling
many units right now.
How do I use this?
-=-=-=-=-=-=-=-=-=
Although there isn't really any software development being done on Acorns
anymore, if you are reading this and are writing something then consider
making it preemptively multitasking. All you have to do is ensure Wimp2 is
loaded (using RMEnsure in your !Run file), and call Wimp2_Initialise instead
of Wimp_Initialise. Call Wimp2_Poll instead of Wimp_Poll, Wimp2_RedrawWindow
instead of Wimp_RedrawWindow or Wimp_UpdateWindow. Call Wimp2_Closedown
instead of Wimp_CloseDown. And oh, you'll need to move your 17,18 & 19
handler into a seperate area so Wimp2 can call it. And that's it - that's all
you need to do - obviously, a great many current applications can be
converted to preemptive multitasking this way.
See the file Docs.APIs and !Wimp2Demo for more exact details.
How does it work?
-=-=-=-=-=-=-=-=-
Firstly, the standard 1cs resolution timer isn't good enough for
preemptive multitasking - get more than ten tasks and the machine crawls.
Really you need at least millisecond resolution, and this is provided by the
Wimp2 module through Wimp2_ReadMonotonicTime, Wimp2_CallAfter and
Wimp2_StopCallAfter.
To preempt a task, every 1 millisecond the IOC timer interrupts the ARM
and the Wimp2 timer dispatch code gets called. It calls the preemptor, which
schedules a user mode callback as Wimp_Poll can only be called from user
code. Next time the OS drops into user mode code (eg; out of an interrupt or
SWI), the secondary preemptor is called in Wimp2. This saves out the current
context not preserved by Wimp_Poll (sprite redirection, fp regs etc), and
calls Wimp_Poll. It then restores everything again, schedules another timer
interrupt, and returns control to the task.
Now all the codes returned by Wimp_Poll are stored in memory, including
any redraw regions, and these are retrieved asynchronously by Wimp2_Poll. If
they are redraws, Wimp2_RedrawWindow is called which suspends preemption and
calls Wimp_UpdateWindow.
As you may have noticed, only user code is preempted. As a result, things
like file operations still lock up the computer, as do any SWI operations as
these run in supervisor mode and RO wasn't built to have supervisor code
preemptively multitasked (well, much of it wasn't - you'd be surprised at how
much of it actually was - that's how RO3 was going to be! - but that's
another story).
Also, if your task calls Wimp2_Poll and there are no messages in the
queue, it loses the remainder of its time slice. In addition, if bit 0 is set
in the poll mask, the task will be halted until the next message arrives (ie;
Wimp2_Poll won't return until a message is there for it).
That is pretty much it. The sources are included, examine them for more
detail if you want.
Bugs:
-=-=-
* If you mask out return of poll codes 4 and 5, Wimp2 currently returns
code 0 whenever 4 or 5 is returned instead of not returning at all. While I
could fix this, the code in this area is really nasty and TBH, for all those
people who wouldn't notice one way or another, I don't think it's worth it.
Email me if you disagree! (thanks to Simon Birtwistle for this)
* Vector assignments (as in OS_Claim ones) aren't saved or restored. This
is easy through OS_DelinkApplication, but it's also very slow. Since 99% of
tasks don't hook onto vectors, I removed the code.
* On RO2, ColourTrans gets its palette tables mucked up by the
sprite redirection. A ColourTrans_InvalidateCache fixes this, but slows RO3+,
so I removed it.
* Wimp2 doesn't reduce its memory allocation at present, only extends it.
Thus some memory may be being wasted.
* The C debugger doesn't like debugging preempted programs. Recompile Wimp2
with redir% set to false to fix this, but you lose sprite redirection when
you do this.
* If your task does redirect VDU output, preemption becomes a major
overhead (it's additional to that task's maximum slice). Sorry, but it's RO's
fault, not mine.
* It would seem (merely from observation) that having Wimp2Ctrl loaded when
loading a new patched program increases vastly the chances of instability. I
don't know why this is (I've tried very hard to find out why), but it's
probably best to not have Wimp2Ctrl loaded when you load a new program.
Features:
-=-=-=-=-
* The support module uses dynamic areas when available (eg; through having
a RiscPC or installing DummyDynamicAreas or whatever) but defaults to using
RMA if these aren't available. Luckily most blocks are small so fragmentation
shouldn't be too much of a problem.
* Works right back to RO2.
* Multiple clients not a problem.
* Works perfectly with Basic.
* Written entirely in lovingly hand-crafted assembler.
* Correctly preempts tasks using floating-point registers and uses multiple
FP stores and loads when available
* Saves and restores the current VDU redirection state
* Patches OS_File to allow preemptively multitasked loads and saves
* Handles the "reply-before-next-Wimp_Poll" problem elegantly and flexibly
in a number of flexible ways.
* Adds 1ms interrupt facilities for use by other code if you wish
* Has variable priorities and monitoring of processor usage
Legal:
-=-=-=
See the file Docs.Legal for details. It's essentially the GNU Public
licence, which in a nutshell means you get the sources and can release your
own modifications or improvements. I would appreciate if you would send
updates to the contact email address below so that one consistent copy can be
maintained.
Credits:
-=-=-=-=
My indebted thanks go to Andrew Teirney for his patch. He has saved me a
lot of work, did a great job and was a pleasure to work with. Cheers Andrew!
Thanks also to Andreas Walter for his help with debugging the StrongARM
OS_File patch problem which took so long to get fixed.
The patch:
-=-=-=-=-=
Probably what will be of most interest to most Acorn users is the ability
to patch existing Wimp apps to use Wimp2 instead of the Wimp - hence they
become preempted just like Wimp2 tasks.
It is difficult to say exactly what will work and what will not. Oddly,
it would seem most major applications work fine - Fireworkz is an example.
OTOH, smaller applications can have problems - Creator won't save files. The
patch, and Wimp2, do make assumptions about how RO apps are written, and if
an application doesn't fully conform to those assumptions then strange
behaviour can result. Both me and Andrew have made provisions for "different"
approaches to writing an application, but we cannot cover every possibility.
Probably the most strange behaviour will occur without the use of the
-compatible switch. Not using this switch allows better preemption and less
halts for compatibility purposes, but things like multiple apps loading the
same double-clicked file will happen. Often it is better to put up with these
annoyances in favour of better multitasking - but you can choose to use
-compatibility on an app by app basis.
The most likely general complaint will be "app X goes too slowly". The
default value of 5ms max slice is usually fine, but especially on heavily
loaded machines there may be a problem. If this is a problem, use -maxslice
to increase its priority on startup. A value of 100 is likely to make the app
run as quick as if it weren't being preempted, as theroretically the bigger
the maxslice the more cooperatively multitasked it is being. However you pay
with less fluid multitasking while the app is busy.
Finally, there have been noted problems with the patch. One is the
Wimp_OpenTemplate bug listed above - another one occurs with menus which open
windows - a too many windows error can result. Finally, due to the different
way Wimp2 handles window redraws, some window redraw problems can occur -
drag a window over the corrupted region to fix this.
Contacts:
-=-=-=-=-
I now have a permanent website at http://www.nedprod.com (it stands for
ned Productions - that's how to remember it). This should be there for the
foreseeable future. It contains pretty much my entire web presence now, along
with the latest copies of many of my programs.
The section for this program is at http://www.nedprod.com/programs
/RISC-OS/Wimp2. Email related to Wimp2 should be sent to wimp2@nedprod.com.
A point is support for this software. I don't do Acorn development much
anymore, and while I will reply to any sensible email I won't necessarily
change any code. That's for you to do - that's why you have the sources.
However please email me any updates so a single master copy can be
maintained.
Niall Douglas
19th May 1999.
Email: wimp2@nedprod.com
Web: http://www.nedprod.com/programs/RISC-OS/Wimp2